<?php
namespace BP\Sys;

use BP\En\EntitiesOID;

class GroupFields extends EntitiesOID {
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String ($enName) // [String enName]
	{
		$me = new self();
		$i = $me->Retrieve(GroupFieldAttr::$FrmID, $enName, GroupFieldAttr::$Idx);
		if (($i == 0))
		{
			$gf = GroupField::constructor__();
			$gf->setFrmID($enName);
			$md = MapData::constructor__();
			$md->setNo($enName);
			if (($md->RetrieveFromDBSources() == 0))
			{
				$gf->setLab("基础信息");
			}
			else
			{
				$gf->setLab($md->getName());
			}
			$gf->setIdx(0);
			$gf->Insert();
			$me->AddEntity($gf);
		}
		return $me;
	}
	public function getNewEntity () 
	{
		return GroupField::constructor__();
	}
	public function RetrieveFieldGroup ($enName) // [String enName]
	{
		$qo = new QueryObject($this);
		$qo->AddWhere(GroupFieldAttr::$FrmID, $enName);
		$qo->addAnd();
		$qo->AddWhereIsNull(GroupFieldAttr::$CtrlID);
		$num = $qo->DoQuery();
		if (($num == 0))
		{
			$gf = GroupField::constructor__();
			$gf->setFrmID($enName);
			$md = MapData::constructor__();
			$md->setNo($enName);
			if (($md->RetrieveFromDBSources() == 0))
			{
				$gf->setLab("基础信息");
			}
			else
			{
				$gf->setLab($md->getName());
			}
			$gf->setIdx(0);
			$gf->Insert();
			$this->AddEntity($gf);
			return 1;
		}
		return $num;
	}
	public function ToJavaList () 
	{
		return $this;
	}
	public function Tolist () 
	{
		$list = [];// 
		for ($i = 0; ($i < $this->size()); ++$i) 
		{
			$list->add($this->get($i));
		}
		return $list;
	}
}
?>
